package com.web.controller;

import com.web.controller.ResponseResult;
import com.web.util.OssUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author lenovo
 * @Description
 * @Date2025-3-20 16:26
 */

@RestController
public class UploadController {
    @RequestMapping("/upload")
    public ResponseResult upload(MultipartFile file) throws IOException {
        //OSS上传
        OssUtils.upload(file.getInputStream(),file.getOriginalFilename());
        //获得url
        String url = OssUtils.getURL(file.getOriginalFilename());
        return new ResponseResult(200,"OK",url);
    }
}
